package src.lab02.test13;

/**
 * Created by MECHREV on 2017/10/25.
 */
public class Gymnastics extends ComputerAverage {
    double []data;
    Gymnastics(){
    }
    Gymnastics(double []data){this.data=data;}
    @Override
    double averge(double[] data) {
        double max,min;
        int a1=0,a2=0;
        max=min=data[0];
        for (int i=0;i<data.length;i++){
            if(data[i]>max){
                max=data[i];
                a1=i;
            }
            else if(data[i]<min){
                min=data[i];
                a2=i;
            }
        }
        data[a1]=0;
        data[a2]=0;
        double sum=0;
        for(int i=0;i<data.length;i++){
            sum+=data[i];
        }
        sum=sum/(data.length-2);
        return sum;
    }
}
